﻿using Basic.FormGatewaryModular.Interface;
using Basic.FormRemoteModel.FormViewCol.Model;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FormGatewaryModular.Api
{
    [ApiRouteName("/form/view/col/{name}")]
    internal class FormViewColApi : ApiController
    {
        private readonly IFormViewColService _Service;

        public FormViewColApi ( IFormViewColService service )
        {
            this._Service = service;
        }

        public long Add ( ViewColAdd data )
        {
            return this._Service.Add(data);
        }
        public ViewCol[] Sync ( ViewColSync data )
        {
            return this._Service.Sync(data);
        }

        public void Delete ( [NumValidate("form.view.col.id.error", 1)] long id )
        {
            this._Service.Delete(id);
        }

        public ViewCol[] Gets ( [NumValidate("form.id.error", 1)] long formId )
        {
            return this._Service.Gets(formId);
        }

        public bool Set ( LongParam<ViewColSet> data )
        {
            return this._Service.Set(data.Id, data.Value);
        }
    }
}
